<template>
  <img :src="image" :style="{width:width,height:height}"/>
</template>

<script>
    import QRCode from "qrcode";
    export default {
        name: "ComQR",
        data: function () {
            return {
                image : ''
            }
        },
        props : {
            url : {
            type : String,
            default : "http://www.pkmb168.cn"
            },
            size : {
                type : Number,
                default: 100
            },
            width : {
                type : String,
                default : "100px"
            },
            height : {
                type : String,
                default : "100px"
            }
        },
        created() {
            this.makeCode();
        },
        methods: {
            async makeCode() {
                let that = this;
                QRCode.toDataURL(this.url).then((res)=>{
                    that.image = res
                }).catch((err)=>{
                  this.$toast({
                    message:err
                  })
                    return false;
                })
            },
        }
    }
</script>

<style scoped>

</style>
